﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
namespace Sbook.Data
{
    public class ProductsInfo
    {
        #region[Declare variables]
        private string _PId;
        private string _PName;
        private string _PCode;
        private string _PPrice;
        private string _PSaleOff;
        private string _PUId;
        private string _CatId;
        private string _AId;
        private string _PActive;
        private string _PAuthor;
        private string _PImg;
        private string _PStatus;
        private string _UomId;
        private string _PNumber;
        #endregion
        #region[Public Properties]
        public string PId { get { return _PId; } set { _PId = value; } }
        public string PName { get { return _PName; } set { _PName = value; } }
        public string PCode { get { return _PCode; } set { _PCode = value; } }
        public string PPrice { get { return _PPrice; } set { _PPrice = value; } }
        public string PSaleOff { get { return _PSaleOff; } set { _PSaleOff = value; } }
        public string PUId { get { return _PUId; } set { _PUId = value; } }
        public string CatId { get { return _CatId; } set { _CatId = value; } }
        public string AId { get { return _AId; } set { _AId = value; } }
        public string PActive { get { return _PActive; } set { _PActive = value; } }
        public string PAuthor { get { return this._PAuthor; } set { this._PAuthor = value; } }
        public string PImg
        {
            get { return this._PImg; }
            set { this._PImg = value; }
        }
        public string PStatus
        {
            get { return this._PStatus; }
            set { this._PStatus = value; }
        }
        public string UomId
        {
            get { return _UomId; }
            set { _UomId = value; }
        }
        public string PNumber
        {
            set { this._PNumber = value; }
            get { return this._PNumber; }
        }
        public string PImg2 { get; set; }
        public string PCreateDate { get; set; }
        #endregion
        #region[Products IDataReader]
        public ProductsInfo ProductsIDataReader(IDataReader dr)
        {
            Data.ProductsInfo obj = new Data.ProductsInfo();
            obj.PId = (dr["PId"] is DBNull) ? string.Empty : dr["PId"].ToString();
            obj.PName = (dr["PName"] is DBNull) ? string.Empty : dr["PName"].ToString();
            obj.PCode = (dr["PCode"] is DBNull) ? string.Empty : dr["PCode"].ToString();
            obj.PPrice = (dr["PPrice"] is DBNull) ? string.Empty : dr["PPrice"].ToString();
            obj.PSaleOff = (dr["PSaleOff"] is DBNull) ? string.Empty : dr["PSaleOff"].ToString();
            obj.PUId = (dr["PUId"] is DBNull) ? string.Empty : dr["PUId"].ToString();
            obj.CatId = (dr["CatId"] is DBNull) ? string.Empty : dr["CatId"].ToString();
            obj.AId = (dr["AId"] is DBNull) ? string.Empty : dr["AId"].ToString();
            obj.PActive = (dr["PActive"] is DBNull) ? string.Empty : dr["PActive"].ToString();
            obj.PAuthor=(dr["PAuthor"] is DBNull)? string.Empty:dr["PAuthor"].ToString();
            obj.PImg = (dr["PImg"] is DBNull) ? string.Empty : dr["PImg"].ToString();
            obj.PStatus = (dr["PStatus"] is DBNull) ? string.Empty : dr["PStatus"].ToString();
            //obj.UomId = (dr["UomId"] is DBNull) ? string.Empty : dr["UomId"].ToString();
            obj.PNumber = (dr["PNumber"].Equals(DBNull.Value)) ? string.Empty : dr["PNumber"].ToString();
            obj.PImg2 = (dr["PImg2"].Equals(DBNull.Value)) ? string.Empty : dr["PImg2"].ToString();
            obj.PCreateDate = (dr["PCreateDate"].Equals(DBNull.Value)) ? string.Empty : dr["PCreateDate"].ToString();
            return obj;
        }
        #endregion
    }
}